package com.hulk.dryad.activiti7.controller;

import com.hulk.dryad.activiti7.api.vo.HistoryDataVO;
import com.hulk.dryad.activiti7.mapstruct.HistoryDataStruct;
import com.hulk.dryad.common.annotation.PrintlnLog;
import com.hulk.dryad.common.component.R;

import com.hulk.dryad.persistence.entity.HistoryData;
import com.hulk.dryad.activiti7.service.IFormHistoryDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(value = "historyFromData", tags = "历史表单数据")
@AllArgsConstructor
@RestController
@RequestMapping("/workflow/historyFromData")
public class HistoryFormDataCoroller {

    private IFormHistoryDataService formHistoryDataService;

	@ApiOperation(value = "historyFromData", notes = "通过实例ID查询历史表单数据")
	@PrintlnLog
    @GetMapping(value = "/show/{instanceId}")
    public R historyFromData(@PathVariable("instanceId") String instanceId) {
		List<HistoryData>  historyDatas =  formHistoryDataService.historyDataShow(instanceId);
		List<HistoryDataVO>  vos = HistoryDataStruct.INSTANCE.from(historyDatas);
        return R.ok(vos);

    }
}
